package thesis.filesharing.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.datanucleus.annotations.Unowned;

@Entity
public class ExerciseFile {
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Key exerciseFileKey;
	
	@Basic
	private String exerciseFileName;
	
	@Basic
	private Long exerciseFileSize;
	
	@Basic
	private String exerciseFileMime;
	
	@Basic
	@Temporal(TemporalType.DATE)
	private Date uploadDate;
	
	@Basic
	private String exerciseFileBlobKey;
	
	@Basic
	private Boolean isParentFile;
	
	@OneToMany(fetch = FetchType.LAZY, targetEntity = ExerciseFile.class)
	private Set<ExerciseFile> childExerciseFiles = new HashSet<ExerciseFile>();
	
	@Basic
	private String fingerprintBlobKey;
	
	@ManyToOne(fetch = FetchType.LAZY)
	private Exercise exercise;
	
	@Unowned
	@ManyToOne(fetch = FetchType.LAZY)
	private Student student;
	
	@Unowned
	@ManyToOne(fetch = FetchType.LAZY)
	private Group group;
	
	public ExerciseFile() {
		
	}

	public ExerciseFile(String exerciseFileName, Long exerciseFileSize,
			String exerciseFileMime, Date uploadDate,
			String exerciseFileBlobKey, Boolean isParentFile) {
		this.exerciseFileName = exerciseFileName;
		this.exerciseFileSize = exerciseFileSize;
		this.exerciseFileMime = exerciseFileMime;
		this.uploadDate = uploadDate;
		this.exerciseFileBlobKey = exerciseFileBlobKey;
		this.isParentFile = isParentFile;
	}

	public ExerciseFile(Key exerciseFileKey, String exerciseFileName,
			Long exerciseFileSize, String exerciseFileMime, Date uploadDate,
			String exerciseFileBlobKey, Boolean isParentFile,
			Set<ExerciseFile> childExerciseFiles, String fingerprintBlobKey) {
		this.exerciseFileKey = exerciseFileKey;
		this.exerciseFileName = exerciseFileName;
		this.exerciseFileSize = exerciseFileSize;
		this.exerciseFileMime = exerciseFileMime;
		this.uploadDate = uploadDate;
		this.exerciseFileBlobKey = exerciseFileBlobKey;
		this.isParentFile = isParentFile;
		this.childExerciseFiles = childExerciseFiles;
		this.fingerprintBlobKey = fingerprintBlobKey;
	}

	public ExerciseFile(String exerciseFileName, Long exerciseFileSize,
			String exerciseFileMime, Date uploadDate,
			String exerciseFileBlobKey, Boolean isParentFile,
			Set<ExerciseFile> childExerciseFiles, String fingerprintBlobKey) {
		this.exerciseFileName = exerciseFileName;
		this.exerciseFileSize = exerciseFileSize;
		this.exerciseFileMime = exerciseFileMime;
		this.uploadDate = uploadDate;
		this.exerciseFileBlobKey = exerciseFileBlobKey;
		this.isParentFile = isParentFile;
		this.childExerciseFiles = childExerciseFiles;
		this.fingerprintBlobKey = fingerprintBlobKey;
	}

	public ExerciseFile(String exerciseFileName, Long exerciseFileSize,
			String exerciseFileMime, Date uploadDate,
			String exerciseFileBlobKey, Boolean isParentFile,
			Set<ExerciseFile> childExerciseFiles, String fingerprintBlobKey,
			Exercise exercise, Student student, Group group) {
		this.exerciseFileName = exerciseFileName;
		this.exerciseFileSize = exerciseFileSize;
		this.exerciseFileMime = exerciseFileMime;
		this.uploadDate = uploadDate;
		this.exerciseFileBlobKey = exerciseFileBlobKey;
		this.isParentFile = isParentFile;
		this.childExerciseFiles = childExerciseFiles;
		this.fingerprintBlobKey = fingerprintBlobKey;
		this.exercise = exercise;
		this.student = student;
		this.group = group;
	}

	public ExerciseFile(String exerciseFileName, Long exerciseFileSize,
			String exerciseFileMime, Date uploadDate,
			String exerciseFileBlobKey, Boolean isParentFile,
			Set<ExerciseFile> childExerciseFiles, String fingerprintBlobKey,
			Exercise exercise) {
		this.exerciseFileName = exerciseFileName;
		this.exerciseFileSize = exerciseFileSize;
		this.exerciseFileMime = exerciseFileMime;
		this.uploadDate = uploadDate;
		this.exerciseFileBlobKey = exerciseFileBlobKey;
		this.isParentFile = isParentFile;
		this.childExerciseFiles = childExerciseFiles;
		this.fingerprintBlobKey = fingerprintBlobKey;
		this.exercise = exercise;
	}

	public Key getExerciseFileKey() {
		return exerciseFileKey;
	}

	public void setExerciseFileKey(Key exerciseFileKey) {
		this.exerciseFileKey = exerciseFileKey;
	}

	public String getExerciseFileName() {
		return exerciseFileName;
	}

	public void setExerciseFileName(String exerciseFileName) {
		this.exerciseFileName = exerciseFileName;
	}

	public Long getExerciseFileSize() {
		return exerciseFileSize;
	}

	public void setExerciseFileSize(Long exerciseFileSize) {
		this.exerciseFileSize = exerciseFileSize;
	}

	public String getExerciseFileMime() {
		return exerciseFileMime;
	}

	public void setExerciseFileMime(String exerciseFileMime) {
		this.exerciseFileMime = exerciseFileMime;
	}

	public Date getUploadDate() {
		return uploadDate;
	}

	public void setUploadDate(Date uploadDate) {
		this.uploadDate = uploadDate;
	}

	public String getExerciseFileBlobKey() {
		return exerciseFileBlobKey;
	}

	public void setExerciseFileBlobKey(String exerciseFileBlobKey) {
		this.exerciseFileBlobKey = exerciseFileBlobKey;
	}

	public Boolean getIsParentFile() {
		return isParentFile;
	}

	public void setIsParentFile(Boolean isParentFile) {
		this.isParentFile = isParentFile;
	}

	public Set<ExerciseFile> getChildExerciseFiles() {
		return childExerciseFiles;
	}

	public void setChildExerciseFiles(Set<ExerciseFile> childExerciseFiles) {
		this.childExerciseFiles = childExerciseFiles;
	}

	public String getFingerprintBlobKey() {
		return fingerprintBlobKey;
	}

	public void setFingerprintBlobKey(String fingerprintBlobKey) {
		this.fingerprintBlobKey = fingerprintBlobKey;
	}

	public Exercise getExercise() {
		return exercise;
	}

	public void setExercise(Exercise exercise) {
		this.exercise = exercise;
	}

	public Student getStudent() {
		return student;
	}

	public void setStudent(Student student) {
		this.student = student;
	}

	public Group getGroup() {
		return group;
	}

	public void setGroup(Group group) {
		this.group = group;
	}
}
